3333import org .openscience .cdk .renderer .RendererModel ;
3434import org .openscience .cdk .renderer .generators .standard .AbbreviationLabel .FormattedText ;
3535import org .openscience .cdk .renderer .generators .standard .StandardGenerator .DeuteriumSymbol ;
36+ import org .openscience .cdk .renderer .generators .standard .StandardGenerator .PseudoFontStyle ;
3637
3738import java .awt .Font ;
3839import java .awt .geom .Rectangle2D ;
@@ -125,13 +126,11 @@ AtomSymbol generateSymbol(IAtomContainer container, IAtom atom, HydrogenPosition
125126 int charge = unboxSafely (pAtom .getFormalCharge (), 0 );
126127 int hcnt = unboxSafely (pAtom .getImplicitHydrogenCount (), 0 );
127128 int nrad = container .getConnectedSingleElectronsCount (atom );
128- if (mass != 0 || charge != 0 || hcnt != 0 ) {
129- return generatePeriodicSymbol (0 , hcnt ,
130- mass , charge ,
131- nrad , position , model );
132- }
129+ return generatePeriodicSymbol (0 , hcnt ,
130+ mass , charge ,
131+ nrad , position , model );
133132 }
134- return generatePseudoSymbol (accessPseudoLabel (pAtom , "?" ), position );
133+ return generatePseudoSymbol (accessPseudoLabel (pAtom , "?" ), position , model );
135134 }
136135 else
137136 return null ; // attach point drawn in bond generator
@@ -159,10 +158,16 @@ AtomSymbol generateSymbol(IAtomContainer container, IAtom atom, HydrogenPosition
159158 *
160159 * @return the atom symbol
161160 */
162- AtomSymbol generatePseudoSymbol (String label , HydrogenPosition position ) {
161+ AtomSymbol generatePseudoSymbol (String label , HydrogenPosition position , RendererModel model ) {
162+
163+ final Font stylisedFont ;
164+ if (model != null && model .get (PseudoFontStyle .class ) != 0 ) {
165+ Integer style = model .get (PseudoFontStyle .class );
166+ stylisedFont = font .deriveFont (style );
167+ } else {
168+ stylisedFont = font ;
169+ }
163170
164- final Font italicFont = font .deriveFont (Font .BOLD )
165- .deriveFont (Font .ITALIC );
166171 List <TextOutline > outlines = new ArrayList <>(3 );
167172
168173 int beg = 0 ;
@@ -177,7 +182,7 @@ AtomSymbol generatePseudoSymbol(String label, HydrogenPosition position) {
177182 pos ++;
178183
179184 if (pos > beg ) {
180- outlines .add (new TextOutline (label .substring (beg , pos ), italicFont ));
185+ outlines .add (new TextOutline (label .substring (beg , pos ), stylisedFont ));
181186 beg = pos ;
182187 // 2a etc.
183188 while (pos < len && isDigit (label .charAt (pos )))
@@ -186,7 +191,7 @@ AtomSymbol generatePseudoSymbol(String label, HydrogenPosition position) {
186191 pos ++;
187192
188193 if (pos > beg ) {
189- TextOutline outline = new TextOutline (label .substring (beg , pos ), italicFont );
194+ TextOutline outline = new TextOutline (label .substring (beg , pos ), stylisedFont );
190195 outline = outline .resize (scriptSize , scriptSize );
191196 outline = positionSuperscript (outlines .get (0 ), outline );
192197 outlines .add (outline );
@@ -221,7 +226,7 @@ AtomSymbol generatePseudoSymbol(String label, HydrogenPosition position) {
221226 }
222227
223228 if (pos < len ) {
224- return new AtomSymbol (new TextOutline (label , italicFont ), Collections .<TextOutline >emptyList ());
229+ return new AtomSymbol (new TextOutline (label , stylisedFont ), Collections .<TextOutline >emptyList ());
225230 } else {
226231 TextOutline outline = null ;
227232 TextOutline ref = outlines .get (outlines .size ()-1 );
@@ -255,7 +260,7 @@ AtomSymbol generatePseudoSymbol(String label, HydrogenPosition position) {
255260 return new AtomSymbol (outlines .get (0 ),
256261 outlines .subList (1 , outlines .size ()));
257262 } else {
258- return new AtomSymbol (new TextOutline (label , italicFont ), Collections .<TextOutline >emptyList ());
263+ return new AtomSymbol (new TextOutline (label , stylisedFont ), Collections .<TextOutline >emptyList ());
259264 }
260265 }
261266
@@ -376,10 +381,12 @@ AtomSymbol generatePeriodicSymbol(final int number, final int hydrogens, int mas
376381 final int unpaired , HydrogenPosition position ,
377382 RendererModel opts ) {
378383
384+ Font myfont = font ;
379385 final String label ;
380386 switch (number ) {
381387 case 0 :
382388 label = "*" ;
389+ myfont = font .deriveFont (Font .BOLD );
383390 break ;
384391 case 1 :
385392 if (mass == 2 && opts .get (DeuteriumSymbol .class )) {
@@ -393,7 +400,7 @@ AtomSymbol generatePeriodicSymbol(final int number, final int hydrogens, int mas
393400 label = Elements .ofNumber (number ).symbol ();
394401 break ;
395402 }
396- TextOutline element = new TextOutline (label , font );
403+ TextOutline element = new TextOutline (label , myfont );
397404 TextOutline hydrogenAdjunct = defaultHydrogenLabel ;
398405
399406 // the hydrogen count, charge, and mass adjuncts are script size
0 commit comments