While generally looks as a good idea, the restriction of setters visibility doesn't seem a valuable change in FontBox (like many other libraries) because there are already quite a lot of public setters (e.g. org.apache.fontbox.ttf.GlyphData#setNumberOfContours) which could allow users to accidentally or deliberately spoil the data gathered from the font. So perhaps it would be enough to introduce a new method only (to get a view of the components) and avoid a breaking change.
Cheers, Vladimir вт, 10 янв. 2023 г. в 01:48, Tilman Hausherr <thaush...@t-online.de>: > On 08.01.2023 13:51, Andreas Lehmkuehler wrote: > > Am 08.01.23 um 13:28 schrieb Tilman Hausherr: > >> Hi, > >> > >> The idea sounds ok to me, the only risk I see would be that somebody > >> changes a GlyfCompositeComp element. > > How about reducing the visibility of both setters to protected and as > > long as we use an unmodifiable list to provide the components there > > shouldn't be any risk or am I overlooking something? > > Yes this makes sense. But we can't do it for 2.0 because this would be > an API break. (We can add a comment) > > Tilman > > > > > > > Andreas > > > >> > >> Tilman > >> > >> On 07.01.2023 14:15, Vladimir Plizga wrote: > >>> Hello, > >>> > >>> I'm starting to use the FontBox library (tried both GA version > >>> 2.0.27 and > >>> the latest pre-release 3.0.0-alpha3) to inspect composite glyphs in > >>> fonts. > >>> In particular, I need to know what exact glyphs (components) are > >>> included into a composite glyph and what transformations have been > >>> applied > >>> to them. However, when I obtain information about a glyph I can only > >>> find > >>> out whether it is composite and how many components are in it. There > >>> is the > >>> org.apache.fontbox.ttf.GlyfCompositeComp class that has (almost) all > >>> the > >>> necessary information, but there is no way to get it from the library > >>> (AFAIS). The closest method to it is the > >>> org.apache.fontbox.ttf.GlyfCompositeDescript#getCompositeComp, but > >>> it is > >>> not suitable because: (1) it's private and (2) it takes point index > >>> as an > >>> argument which is out of scope for this particular task (as I work > >>> with the > >>> glyph at whole but not with its particular points). > >>> > >>> I suppose there is some deliberate design decision behind this > >>> limitation, > >>> but it really hinders "to obtain low level information from font > >>> files" (as > >>> stated in the library description). > >>> > >>> As a possible solution, I would suggest to supplement > >>> org.apache.fontbox.ttf.GlyfCompositeDescript class with a new method > >>> like > >>> this: > >>> > >>> /** > >>> * Gets a view to the composite components > >>> * @return unmodifiable list of this composite glyph's {@linkplain > >>> GlyfCompositeComp components} > >>> */ > >>> public List<GlyfCompositeComp> getComponentsView() { > >>> return Collections.unmodifiableList(components); > >>> > >>> } > >>> , which is aimed to provide a read-only view of the components of a > >>> composite glyph. Or provide a similar method for getting a particular > >>> component by its index. In either case it would also be needed to > >>> make the > >>> static flag masks public in org.apache.fontbox.ttf.GlyfCompositeComp > >>> class > >>> (since now they are protected). > >>> > >>> Could you please comment on the described limitation and the suggested > >>> solution (if it makes sense of course)? > >>> > >>> Cheers, > >>> Vladimir > >>> > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > >> For additional commands, e-mail: users-h...@pdfbox.apache.org > >> > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > > For additional commands, e-mail: users-h...@pdfbox.apache.org > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > For additional commands, e-mail: users-h...@pdfbox.apache.org > >