Hi Tim,
Sorry, the font size setting both within the code and in the public
interface has been a fraught matter since Freetype was introduced for the
font drawing and it isn't currently as controllable as one might wish.  The
font is chosen based on baseFontSize and the drawing scale.  The size of
the font relative to the bond lengths is therefore fixed, unless it hits
the minFontSize or maxFontSize.  So for a large molecule in a small canvas,
it is likely that the font size will be larger relative to the bonds as
minFontSize has an effect, and vice versa with a small molecule in a large
canvas.  To achieve what you want, you need to increase bastFontSize,
which, as Paolo mentioned, isn't currently exposed to Python.  Apologies
for that, which was an oversight.  It does work with the current release,
though, so if you don't mind rebuilding RDKit you can use it now.
Add
```

      .def_readwrite(

          "baseFontSize", &RDKit::MolDrawOptions::baseFontSize,

          "relative size of font.  Defaults to 0.6.  -1 means use default.")
```
to $RDBASE/Code/GraphMol/MolDraw2D/Wrap/rdMolDraw2D.cpp immediately after
the analogous minFontSize entry
HTH,
Dave



On Wed, Feb 9, 2022 at 10:31 AM Tim Dudgeon <tdudgeon...@gmail.com> wrote:

> OK, thanks. That's great to hear.
> In the meantime could someone explain how the font is currently chosen?
> e.g. if I specify 10 as min and 14 as max what is actually used?
> Tim
>
> On Wed, Feb 9, 2022 at 10:11 AM Paolo Tosco <paolo.tosco.m...@gmail.com>
> wrote:
>
>> Hi Tim,
>>
>> Dave Cosgrove is currently working at a PR which, among other things,
>> addresses exactly the need that you describe through the baseFontSize
>> parameter, which is currently not exposed to Python. The PR is almost ready
>> for merging and it should become part of the March release.
>>
>> Cheers,
>> p.
>>
>> On Wed, Feb 9, 2022 at 10:57 AM Tim Dudgeon <tdudgeon...@gmail.com>
>> wrote:
>>
>>> I'm confused over how the font is chosen when drawing molecules.
>>> There are MolDrawOptions.minFontSize and MolDrawOptions.maxFontSize
>>> properties, and if I set them to the same value then that sized font is
>>> used. But if I set max to a larger size than min then it's not clear what
>>> font size will be used.
>>> I'm wanting the font size to adapt to the amount the molecule is scaled
>>> to fit the space (larger molecules needing a smaller font) but I want the
>>> font size that is used to be a bit bigger than the default that would be
>>> used if I don't set anything.
>>> How do I go about this?
>>> Thanks
>>> Tim
>>> _______________________________________________
>>> Rdkit-discuss mailing list
>>> Rdkit-discuss@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>>
>> _______________________________________________
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>


-- 
David Cosgrove
Freelance computational chemistry and chemoinformatics developer
http://cozchemix.co.uk
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to