On Mon, 14 Jul 2025 13:43:40 GMT, Nikita Gubarkov <ngubar...@openjdk.org> wrote:
>> @prrace about tests. I can draw test image with font which is support tnum >> feature, and validate without it. Primitive one. >> >> For example >> * at start - need load font, which supports this features. For example >> `Inter` (also need attach license of it inside repo?) >> * draw image `0123456789` with `pnum` >> * <img width="200" height="50" alt="pnum" >> src="https://github.com/user-attachments/assets/2e80a463-a608-425f-a264-6097e415d397" >> /> >> * draw image `0123456789` with `tnum` >> * <img width="200" height="50" alt="tnum" >> src="https://github.com/user-attachments/assets/62600f4e-1094-4fce-bd09-3876b4a8610e" >> /> >> * if all bytes of images equals - it's means `tnum` not works. >> >> Also check default instance of `Font` without options >> >> We can add this images inside repo, and validate image drawing (not sure) > > @VISTALL You can take a look at > https://github.com/openjdk/jdk/blob/bcd86d575fe0682a234228c18b0c2e817d3816da/test/jdk/java/awt/font/TextLayout/FormatCharAdvanceTest.java > - it has a good example of synthetic font generated specifically for the > test and embedded into the test as base64. This avoids the hussle with > licences and whatnot. > I would also suggest to avoid golden-image tests, as those tend to be > burdensome to maintain. But in your case you can probably inspect line > metrics and compare the widths of a sample text. > @YaaZ Thanks for example. About API. Will be good to make universal api - but > I think it's too big task will be. > > Maybe introduce api like nio2 - CopyOption* etc. > > for example > > ```java > interface FontFeature<V> (FontExtension?) { > // some code > } > > // V is Integer? or delegate to impl > class OpenTypeFontFeature implements FontFeature<Integer > { > OpenTypeFontFeature (String name) { > } > } > > public final class OpenTypeFontFeatures { > FontFeature<Integer> TABULAR_NUMBERS = new OpenTypeFontFeature<> ("tnum"); > } > ``` > > There few questions: > > * conflicting features? > * need method `Font#supportsFeature(FontFeature)` ? > * need opentype class? or utilize to default font naming? (eg FontFeatureImpl) > * need make public `OpenTypeFontFeature` class? (accesing from clients) > * FontFeature will be extends TextAttribute? I have previously prototyped APIs in this area. And they inter-operate with other ideas. I'm working on other things right now so I can't switch gears to that but it probably does make sense to pause on this until I can think about whether this API on its own makes sense. ------------- PR Comment: https://git.openjdk.org/jdk/pull/26144#issuecomment-3156744114