RFR: 8360136: RFE: Add TextAttributes for OpenType font figure style features [v2]

Valery Semenchuk duke at openjdk.org
Sat Jul 12 08:12:41 UTC 2025


On Fri, 11 Jul 2025 19:33:17 GMT, Phil Race <prr at openjdk.org> wrote:

>> Valery Semenchuk has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR. The pull request contains one new commit since the last revision:
>> 
>>   8360136: introducing TextAttribute#PROPORTIONAL_FIGURES and TextAttribute#TABULAR_FIGURES for controlling Font figure styles
>
> src/java.desktop/share/classes/java/awt/font/TextAttribute.java line 1122:
> 
>> 1120:      * <p>The constant value {@link #PROPORTIONAL_FIGURES_ON} is defined.
>> 1121:      *
>> 1122:      * <p>Conflicts with {@link #TABULAR_FIGURES}
> 
> True. So at an API level, should it be allowed to specify both at the same time ?
> Perhaps instead the attribute should be called FIGURE_WIDTH and have values of PROPORTIONAL and TABULAR
> But what about the other figure related 'standard' opentype features : lining and old style ?
> 
> https://learn.microsoft.com/en-us/typography/opentype/spec/features_ko#lnum
> https://learn.microsoft.com/en-us/typography/opentype/spec/features_ko#onum
> 
> They are the same idea but it affects height / vertical positioning instead of width
> 
> So do we add FIGURE_HEIGHT too with values of LINING and OLDSTYLE ?
> 
> Or .. do we add 
> FIGURE_STYLE and provide the combinations  like
> TABULAR_LINING and PROPORTIONAL_OLDSTYLE ?
> 
> There'd be 16 values so I am not sure about that.
> May be have the WIDTH and HEIGHT options and let people select the pairs they want.
> Also it means if they 'don't care" about one or the other they can just not set it instead of thinking.

Hello. Main idea - is to provide access to control this features in a simple way, without modification native & java too much.

Conflict described only in JavaDoc since - I don't want add special throws inside `Font` constructor with this options.

About what you say. Yes - I thought about that, but it's too big change. 

For example - will be nice move control hb features control from C++ code to Java. For now it's controlled by flags, and not flexable. 

What do you think about this api:


// internal api in sun.font

// enum for better control values, since there no sense give access to set 3,4,5+ values
public enum EFigureWidth {
    // unset? unknown? undefined?
    UNSET,
    PROPORTIONAL_FIGURES, // pnum=1
    TABULAR_FIGURES       // tnum=1
}

// public api
public class TextAttribute {

    public static final TextAttribute FIGURE_WIDTH = new TextAttribute("figure-width");

    public static final Object FIGURE_WIDTH_UNSET = EFigureWidth.UNSET;
    
    public static final Object FIGURE_WIDTH_TABULAR = EFigureWidth.TABULAR_FIGURES;

    public static final Object FIGURE_WIDTH_PROPORTIONAL = EFigureWidth.PROPORTIONAL_FIGURES;

    // same for figure height
}

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26144#discussion_r2202427915


More information about the client-libs-dev mailing list