diff options
Diffstat (limited to 'include/core/SkFontHost.h')
-rw-r--r-- | include/core/SkFontHost.h | 72 |
1 files changed, 34 insertions, 38 deletions
diff --git a/include/core/SkFontHost.h b/include/core/SkFontHost.h index e20ea05..c549519 100644 --- a/include/core/SkFontHost.h +++ b/include/core/SkFontHost.h @@ -1,19 +1,12 @@ + /* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 + * Copyright 2006 The Android Open Source Project * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ + #ifndef SkFontHost_DEFINED #define SkFontHost_DEFINED @@ -31,7 +24,7 @@ typedef uint32_t SkFontTableTag; This class is ported to each environment. It is responsible for bridging the gap between the (sort of) abstract class SkTypeface and the platform-specific implementation that provides access to font files. - + One basic task is for each create (subclass of) SkTypeface, the FontHost is resonsible for assigning a uniqueID. The ID should be unique for the underlying font file/data, not unique per typeface instance. Thus it is @@ -43,7 +36,7 @@ typedef uint32_t SkFontTableTag; returned). Either way, the fontID for those instance(s) will be the same. In addition, the fontID should never be set to 0. That value is used as a sentinel to indicate no-font-id. - + The major aspects are: 1) Given either a name/style, return a subclass of SkTypeface that references the closest matching font available on the host system. @@ -72,17 +65,17 @@ public: /** Return a new typeface given the data buffer. If the data does not represent a valid font, returns null. - + If a typeface instance is returned, the caller is responsible for calling unref() on the typeface when they are finished with it. - + The returned typeface may or may not have called ref() on the stream parameter. If the typeface has not called ref(), then it may have made a copy of the releveant data. In either case, the caller is still - responsible for its refcnt ownership of the stream. + responsible for its refcnt ownership of the stream. */ static SkTypeface* CreateTypefaceFromStream(SkStream*); - + /** Return a new typeface from the specified file path. If the file does not represent a valid font, this returns null. If a typeface is returned, the caller is responsible for calling unref() when it is no longer used. @@ -90,13 +83,13 @@ public: static SkTypeface* CreateTypefaceFromFile(const char path[]); /////////////////////////////////////////////////////////////////////////// - + /** Returns true if the specified unique ID matches an existing font. Returning false is similar to calling OpenStream with an invalid ID, which will return NULL in that case. */ static bool ValidFontID(SkFontID uniqueID); - + /** Return a new stream to read the font data, or null if the uniqueID does not match an existing typeface. .The caller must call stream->unref() when it is finished reading the data. @@ -145,7 +138,7 @@ public: static SkTypeface* Deserialize(SkStream*); /////////////////////////////////////////////////////////////////////////// - + /** Return a subclass of SkScalarContext */ static SkScalerContext* CreateScalerContext(const SkDescriptor* desc); @@ -188,10 +181,17 @@ public: names, etc.) should be populated. @return The returned object has already been referenced. NULL is returned if the font is not found. + @param glyphIDs For per-glyph info, specify subset of the font by + giving glyph ids. Each integer represents a glyph + id. Passing NULL means all glyphs in the font. + @param glyphIDsCount Number of elements in subsetGlyphIds. Ignored if + glyphIDs is NULL. */ static SkAdvancedTypefaceMetrics* GetAdvancedTypefaceMetrics( SkFontID fontID, - SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo); + SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo, + const uint32_t* glyphIDs, + uint32_t glyphIDsCount); /** Return the number of tables in the font */ @@ -206,7 +206,7 @@ public: /** Given a table tag, return the size of its contents, or 0 if not present */ static size_t GetTableSize(SkFontID, SkFontTableTag); - + /** Copy the contents of a table into data (allocated by the caller). Note that the contents of the table will be in their native endian order (which for most truetype tables is big endian). If the table tag is @@ -232,20 +232,9 @@ public: /////////////////////////////////////////////////////////////////////////// - /** Return the number of bytes (approx) that should be purged from the font - cache. The input parameter is the cache's estimate of how much as been - allocated by the cache so far. - To purge (basically) everything, return the input parameter. - To purge nothing, return 0 - */ - static size_t ShouldPurgeFontCache(size_t sizeAllocatedSoFar); + /** DEPRECATED -- only called by SkFontHost_FreeType internally - /** Return SkScalerContext gamma flag, or 0, based on the paint that will be - used to draw something with antialiasing. - */ - static int ComputeGammaFlag(const SkPaint& paint); - - /** Return NULL or a pointer to 256 bytes for the black (table[0]) and + Return NULL or a pointer to 256 bytes for the black (table[0]) and white (table[1]) gamma tables. */ static void GetGammaTables(const uint8_t* tables[2]); @@ -286,7 +275,7 @@ public: static void SetSubpixelOrder(LCDOrder order); static LCDOrder GetSubpixelOrder(); -#ifdef ANDROID +#ifdef SK_BUILD_FOR_ANDROID /////////////////////////////////////////////////////////////////////////// /** @@ -297,7 +286,14 @@ public: */ static uint32_t GetUnitsPerEm(SkFontID fontID); #endif + + /** If Skia is running in a constrained environment and the typeface + implementation is handle based, the typeface data may become + unavailable asynchronously. If a font host or scaler context method is + unable to access font data, it may call this function as a request to + make the handle contained in the typeface useable. + */ + static void EnsureTypefaceAccessible(const SkTypeface& typeface); }; #endif - |