blob: d79909eaffa87c0aea0945644e6727c344abdfaf [file] [log] [blame]
Alex Sakhartchouk9b949fc2010-06-24 17:15:34 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.renderscript;
18
19import java.io.IOException;
20import java.io.InputStream;
21
22import android.content.res.Resources;
23import android.content.res.AssetManager;
24import android.util.Log;
25import android.util.TypedValue;
26
27/**
28 * @hide
29 *
30 **/
31public class Font extends BaseObj {
32
33 Font(int id, RenderScript rs) {
Alex Sakhartchouk0de94442010-08-11 14:41:28 -070034 super(id, rs);
Alex Sakhartchouk9b949fc2010-06-24 17:15:34 -070035 }
36
37 static public Font create(RenderScript rs, Resources res, String fileName, int size)
38 throws IllegalArgumentException {
39
40 rs.validate();
41 try {
42 int dpi = res.getDisplayMetrics().densityDpi;
43 int fontId = rs.nFontCreateFromFile(fileName, size, dpi);
44
45 if(fontId == 0) {
46 throw new IllegalStateException("Load loading a font");
47 }
48 Font rsFont = new Font(fontId, rs);
49
50 return rsFont;
51
52 } catch (Exception e) {
53 // Ignore
54 }
55
56 return null;
57 }
58}