Matplot LaTeX Rendering in cmss style - matplotlib

is it possible to render text as well as math symbols in the cmss (Computer Modern Sans-Serif) style within Matplotlib? I managed to render all text in cmss style but math symbols were still in the normal serif style. I then tried to use the cmbright package within the loaded preamble which admittedly resulted in everything (text + math) having a sans-serif style but the new style wasn't exactly cmss but a slightly lighter version of it. I would like to know if there is a way of rendering everything in the cmss style as this is the font for headings in the document I'm currently working on.
Thanks in advance!

Related

Native Base Medium/Bold fonts show up the same as Regular font

I'm building a react native app, and I've linked my fonts to my projects. For iOS, i'm having trouble with the font variations. I am using the Roboto font family, and no matter what font weight variation I use, it shows up as "Roboto-Regular".
If I do:
fontFamily: 'Roboto-Medium' or
fontFamily: 'Roboto-Bold'
It displays the same as Roboto-Regular. I am not having this issue in Android. The fonts folder is added to the Bundle Resources, and to the info.plist.
Just to test things out further if i do:
fontFamily: 'Roboto-sMedium' it will show a warning message "Unrecognized fontFamily", and revert to a system default font.
There is no problem in xcode recognizing the font family, but I cannot get the Medium and Bold variations to show properly.
Any suggestions?
--edit--
I figured out this was an issue with the Native Base elements I am using, where the style attributes were not recognizing the font weight variations on any Native Base elements.
For example, the <Text> element from Native Base didn't recognize the font weight variation of style={{fontFamily: 'Roboto-Medium'}}
If I switched to the react native <Text> element it would work appropriately.
I realize that you need to customize the them in Native Base to use the font properties as noted here:
https://docs.nativebase.io/customizing-fonts
However, I did not expect that the font-family style attributes would not work.

How to render mathematical on PDF documents

I am trying to render mathematical expressions to a PDF document using a low-level library such as libharu or pdflib; I am having problem rendering several special signs, such as radical signs.
A solution I can think of is to use draw line methods to render the radical sign. This is straightforward. But this doesn't work for integrate or other signs such as "\left(". I consulted KaTeX source code and I found it uses a built in svg graphics, which is not applicable when rendering a PDF document
(Maybe I was not making it clear: the svg presented in KaTeX was actually a glyph pre-rendered, while my application scenario is to render PDF directly with couple of given parameters, such as position and height, etc. ).
Are there anyone who know the PDF rendering mechanism of LaTeX or similarly stuffs that can help me out? thank you in advance!

webvtt position wrong when using css translate on parent (slider)

In my project I'm using swiper.js as a slideshow, each slide either contains and image or a html5 video with webvtt captions / subtitles.
On debugging, we noticed that the subtitle position is wrong (too low, cuts off screen) on webkit browsers.
After much debugging it turned out that this css3 rule on the parent div (the swiper-wrapper) makes the vtt position wrongly:
transform: translate3d(-1024px, 0px, 0px)
When you put the video in the first slide, all goes well, since there's no css translate yet.
This seems to be a core webkit issue: default webvtt positioning breaks when using css translation on a parent.
The workaround I found is to add a line positioning in the vtt itself to every subtitle element, like so:
WEBVTT
00:00:02.160 --> 00:00:06.440 line:90%
hello world
00:00:06.560 --> 00:00:11.920 line:90%
testing subtitles
Any sentence without the "line: 90%" part is rendered partly offscreen. It seems this setting forces the webvtt parser / renderer to set itself to the correct position.
QUESTION: did anyone encounter this issue yet and is there any other (easier) workaround for this bug? Adding the "line:" part to all subtitles would be a hell of a job.. unless there's a good editor that can do that stuff in batch.
QUESTION 2: Since this seems to be a webkit vtt parser bug, anyone know where to best report this?
Test setup here: http://orgonemedia.nl/webvtt-bug/
I'm currently debugging some WebVTT files for English captions and other languages too. I'm experiencing a similar problem, although I can't say what is exactly causing it. I'm going to try the line:90% fix you've suggested here.
ANSWER TO YOUR QUESTION 1: Regarding the job of adding it to all the subtitles, you'll be happy to know that's actually pretty easy with the right tool. I use Sublime Text Editor. The way I would do it is use "Find all" to find all the occurrences of -->, then simultaneously edit each of those lines, using the arrow key to navigate across to the right place on the line (since each subtitle out-time is the same number of characters, 12), then type in line:90%
UPDATE:
So I implemented your suggestion, using the method I outlined, and it successfully repositioned my captions.
More details: I was only experiencing the problem of captions being half off the bottom of the video when viewing on an iPad. Oddly enough, viewing the same page on an iPhone, they were positioned correctly without any change. The 90% change still adjusted it up though.
Intriguingly the line:90% code does nothing to adjust caption position when viewing the page on Chrome.
I'm having trouble getting much at all to display on Safari desktop. I think there's something invalid about my file format, but I'm darned if I can find it.
When editing the captions through my video hosting service's caption editor (I'm using JWPlayer), the timecodes show up as being invalid:
Image showing caption editor with invalid warning

Font hinting behavior in PhantomJS?

I need to render text contained within divs on HTML document into PDF. I'm thinking of using PhantomJS, but one thing is very important. Different browsers and platforms render the text differently. So if I have the following code:
<div style='width:150px; height:80px; position:absolute; top:130px; left:78px'>
<p> Some text, yayy! :) </p>
</div>
It may render on one browser like this:
Some text, yayy!:)
But on another like this:
Some text,
yayy!:)
What happened was that (because of font-hinting, I guess), the text in the first example ended up with a certain width that fit into the containing div, but because of the font rendering on the second browser, the text ended up taking just a little more space that didn't fit in the container, and had to wrap around to the next line. I can't afford this kind of unreliability on how the output turns out. If the HTML had it on one line, I need the PDF to have on the same line too.
I've actually asked a related question here: Make fonts on Windows render like Mac/Linux: disabling font-hinting and/or deal with anti-alias on client side with no luck, but it was basically in trying to solve this same issue.
Can PhantomJS do anything about this? Or can PhantomJS at least somehow calculate the true width of a text, without font hinting and any other things involved? Or maybe calculate what it might render to if hinting were included? Or anything, as long as things come out on the PDF as they look on HTML. (Given the application I'm working on, I do not have the freedom change the CSS style of the containing DIV).
Font hinting is almost certainly not what is changing the width of text here. Font hinting involves making small adjustments to line up edges in an outline font to screen pixels; the adjustments are made within each character and should not change the overall width of that character.
Across platforms, there are slightly different versions of a font because of licensing issues. macOS and GNU/Linux can't usually go out and copy Microsoft's fonts exactly, for legal reasons, so the nearest you'll get is a font that basically looks the same (and has a similar name) but isn't really the same font. So some width variations across platforms are to be expected, unless you can provide your own font files along with the page (web fonts).
PhantomJS uses the system's fonts just like any other browser. So using PhantomJS will not automatically give you some "cross-platform" set of fonts that's different from your system fonts.
If you need 100% reproducibility then I suggest creating a virtual machine (or Docker image) with a standard set of fonts installed, and use that everywhere. Just don't forget to apply security patches to it when needed.

How can I allow the user to style font in NSTextView using interface buttons in xcode?

In short:
I am trying to find information about text styling inside an NSTextView. Bold, italics, indentation, making a word completely uppercase and setting backdrop colors to certain lines.
Any and all info is welcome. I've been looking around the web for docs on the subject and only managed to find a few things that seem to be part of an iphone framework. I'm sure there must be something out there and that I'm just searching for the wrong words.
A few details:
I am not a developer. I am a motion graphics artist and screenwriter. I do know html, php, javascript, css and several scripting languages (all very similar to javascript) used by different graphics apps.
I am not very proficient in objective-c but I've taken up writing a screenwriting app as a bit of a side project. I've been teaching myself objective-c from a book call Cocoa Programming for Mac OSX and using the code I've created from the examples in the book to create my app using Xcode. Styling text was not covered and I am at a loss as to how to approach it.
Screenplays have very specific formats. Using css I could create this format easily so my first thought was to find out if text inside a NSTextview can have css applied to it. I've not found anything that could answer this. Of course I am probably way off with this approach.
Again, any help or anyone who can point me in the right direction would be extremely appreciated.
Thanks!
-Omar
You can't do this because it only accept one style.
You have to deal with UIWebView Tutorial for this and use your CSS.
Or you can use some code like EGOTextView. I do not test this but I think it will be the easiest way for you.