LoginSignup
1
0

More than 1 year has passed since last update.

邦訳) FreeType 2 Cache subsytem

Posted at

Cache Sub-System

Synopsis

This section describes the FreeType 2 cache sub-system, which is used to limit the number of concurrently opened FT_Face and FT_Size objects, as well as caching information like character maps and glyph images while limiting their maximum memory usage.

このセクションでは、FreeType 2 cache sub-systemについて記述します。これは同時に開くFT_FaceとFT_Size objectの数に制約を課しながら、character mapsとglyph imageをメモリ使用量上限の制限を課しながら、情報をキャッシュとして用います。

Note that all types and functions begin with the FTC_ prefix.

全てのtypeと関数は、FTC_ prefixから始まる事に注意して下さい。

The cache is highly portable and thus doesn't know anything about the fonts installed on your system, or how to access them. This implies the following scheme:

cacheは移植性が高いため、システムにどのようなフォントが含まれているのか、どのようにアクセスするのかを知りません。これは以下のスキーマを意味します。

First, available or installed font faces are uniquely identified by FTC_FaceID values, provided to the cache by the client. Note that the cache only stores and compares these values, and doesn't try to interpret them in any way.

第1に、有効であるあるいはインストールされているfont faceは、clientによってキャッシュに与えられるFCT_FaceID valueによってユニークな識別性を持ちます。キャッシュはこれらの値を記憶し、比較する事しかしません。何かしらの方法で解釈しようとはしません。

Second, the cache calls, only when needed, a client-provided function to convert an FTC_FaceID into a new FT_Face object. The latter is then completely managed by the cache, including its termination through FT_Done_Face. To monitor termination of face objects, the finalizer callback in the generic field of the FT_Face object can be used, which might also be used to store the FTC_FaceID of the face.

第2に、cacheは必要に応じて、clientが提供するFTC_FaceIDから新しいFT_Face objectに変換するための関数を呼び出します。後者FT_Faceは、cacheによって完全に管理されます。FT_Done_Faceによる終了も含まれます。face objectの終了を監視するために、FT_Face objectの汎用fieldないのfinalizer callbackを利用する事も出来ます。これは、faceのFTC_FaceIDを保持するためにもつかわれます。

Clients are free to map face IDs to anything else. The most simple usage is to associate them to a (pathname,face_index) pair that is used to call FT_New_Face. However, more complex schemes are also possible.

Clients、FaceIDを他のものへ自由にマッピングできます。 最も簡単な使用法は、FT_New_Faceの呼び出しに用いられる(pathname、face_index)ペアに関連付けることです。 ただし、より複雑なスキームを用いることもできます。

Note that for the cache to work correctly, the face ID values must be persistent, which means that the contents they point to should not change at runtime, or that their value should not become invalid.

cacheが正常に動作するためには、face ID valueが永続的である必要があります。つまり、FactIDが示すコンテンツは、実行時において変更されたり無効化されたりしないようにする必要があります。

If this is unavoidable (e.g., when a font is uninstalled at runtime), you should call FTC_Manager_RemoveFaceID as soon as possible, to let the cache get rid of any references to the old FTC_FaceID it may keep internally. Failure to do so will lead to incorrect behaviour or even crashes.

(例えば、実行時にフォントがアンインストールされるなど)これが避けられない場合には、FTC_Manager_RemoveFaceIDを出来るだけ早く呼び出してください。cacheは内部で保持している古いFTC_FaceIDへの参照を削除しようとします。そうしないと、お菓子な振る舞いになったりクラッシュしたりします。

To use the cache, start with calling FTC_Manager_New to create a new FTC_Manager object, which models a single cache instance. You can then look up FT_Face and FT_Size objects with FTC_Manager_LookupFace and FTC_Manager_LookupSize, respectively.

cacheを使うためには、最初に、単一のcache instanceをモデル化する、新しいFTC_Manager objectを作るために FTC_Manager_Newの呼び出してください。FTC_Manager_LookupFaceとFTC_Manager_LookupSizeをそれぞれ使用してFT_Face objectとFT_Size objectを検索できます。

If you want to use the charmap caching, call FTC_CMapCache_New, then later use FTC_CMapCache_Lookup to perform the equivalent of FT_Get_Char_Index, only much faster.

charmap cacheを使用する場合、FTC_CMapCache_Newを呼び出し、後でFTC_CMapCache_Lookupを使用してください。FT_Get_Char_Indexと同等の処理をはるかに高速に実行します。

If you want to use the FT_Glyph caching, call FTC_ImageCache_New, then later use FTC_ImageCache_Lookup to retrieve the corresponding FT_Glyph objects from the cache.

FT_Glyph cacheを使用する場合、FTC_ImageCache_Newを呼び出し、後でFTC_ImageCache_Lookupを使用して、対応するFT_Glyphオブジェクトをキャッシュから取得します。

If you need lots of small bitmaps, it is much more memory efficient to call FTC_SBitCache_New followed by FTC_SBitCache_Lookup. This returns FTC_SBitRec structures, which are used to store small bitmaps directly. (A small bitmap is one whose metrics and dimensions all fit into 8-bit integers).

多数のsmall bitmapsが必要な場合は、FTC_SBitCache_Newを呼び出してからFTC_SBitCache_Lookupを呼び出す方が遥かにメモリ効率が高くなります。 これにより、FTC_SBitRec構造体が返されます。これは、small bitmapsを直接格納するために使用されます。 (small bitmapsとは、metricsとdimensionsがすべて8ビット整数に収まるビットビットです)。

We hope to also provide a kerning cache in the near future.

近い将来、kerning cacheもまた提供したいと考えています。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0