iOS 8 WKWebView: display local plain text like iOS 9? - ios

I'm attempting to view a local log file using a WKWebView, due it's higher performance and asynchronous loading vs. UITextView. On iOS 9, the loadFileURL(_:allowingReadAccessToURL:) works perfectly to load the plain text file and display it. It even renders with a monospaced font (I wish I could set it to Menlo though). However, on iOS 8, local file URLs can't be loaded but I can load the text file as a String and use loadHTMLString(_:baseURL:) to load it into the view. This works, but the text is rendered, as expected, as if it was HTML. That means there are no line breaks or appropriate wrapping for long lines. It also renders with the default font, which is not monospaced.
I'm guessing I could attempt to load some JavaScript that loads some styling, but I have no experience with that and I'm hesitant to put that much effort into what's essentially debug log viewer.
So my question is, how can I render plain text as plain text, from a local file, using WKWebView on iOS 8?

Related

I am trying to replace the Tooltip placeholder, $i18n{tooltipZoomOut}, in a PDF file loaded into TChromium

I have a Delphi 10.3 application and it uses TChromium to load local HTML files.
This works fine, and I can navigate to a PDF in the same window and it loads via Chrome's PDF handler.
The only problem I have is when hovering over the default buttons in the PDF viewer (such as Zoomin, print etc), I get what looks like the tooltip placeholder before it gets replaced with localized text.
$i18n{tooltipZoomOut} is the tooltip on the zoom out button, instead of nicer tooptip text. I can not find how to change this. I am not sure if it's something I can configure within Delphi or if I need to include a language file which Chromium will use.

Using custom font inside UserControl is making my font bold

When I use my fonts outside of user controls I have them loading correctly. But when the word has accent and is inside UserControl the font is appearing in bold, I've tested more than one font and the problem happens.
In the image I inserted a sentence written on top of the whole frame in the same way as a sentence written inside a UserControl, what is outside proves that the accents work without being bold and inside shows that all the words that are accented are in bold.
The problem only happens on iOS.
I found the problem. I had edited some texts in another editor (VSCode) and also copied some others from another platform that we used, the problem happened due to the encode of these other tools, when pasting in VStudio it caused the problem.
Just rewriting the texts directly by VStudio and the problem has been fixed.

How to get the fonts being used in a UILabel and the ranges they span for PDF generation?

I'm currently developing an iOS app that at a very high level allows a user to enter text into a text box that will get sent to a server for incorporation into a dynamically generated PDF. The server uses Node.js & PDFKit.
We are localising the app for pretty much every language supported by iOS. The text the user enters is UTF-8 encoded when sent to the server. The problem I face is knowing which font (or fonts) to use server side to ensure the characters show up correctly in the server side generated PDF.
In the iOS client app there is a single UILabel showing a preview of the text a user has entered into a UITextField. The UILabel showing the preview has a single custom font applied that only has support for Greek & Latin characters. Interestingly when a mixture of characters are entered from different alphabets (possible if the user has multiple keyboards) latin, cyrillic, etc. they display correctly in the UILabel despite the fact the custom font does not support them:
I guess there is some kind of "font fallback" going on, however as the client app is being localised to support many languages this behaviour is desirable.
My question is how can I know server side which fonts are being used, and the range of characters they cover in the preview UILabel? Somehow I need to replicate this behaviour server side so that the text in the generated PDF approximately matches the client preview.
Alternatively is it possible to determine server side what fonts I should use for a given character?

when using UIWebview and dropdown, ios7 picker doesn't wrap the text.

I have an application that uses Webview in iOS7. I was wondering if there is anyway via CSS or HTML to tell the picker to wrap the text instead of showing "...". iOS 6 would wrap the text but in IOS 7 the text gets ... after 25 characters.
Thanks,
Faraz
I fear that's not possible.
The Webkit used in the UIWebview uses the same UIPickerView as native apps, and there's no way to customise it via CSS nor JS etc.
It looks like the ellipsis it adds in the text is the new behaviour of UIPickerView itself in iOS7.
If you really need to customise the picker, you should implement one in HTML, CSS, JS etc, by yourself.
If think it worth the effort, you should also take a look at Sencha Touch's picker.

Dynamically Paginating .epub files in UIWebView

I am loading files from an .epub into UIWebViews for display. At the moment, the .epub is divided into individual files for each chapter. To display the chapters, I am just loading these files into UIWebView. I am trying to figure out how to break these down into pages depending on font size, styling, etc. It's proving difficult, as iOS only accesses the UIWebView content indirectly. Is there a standard method for breaking it up?
I'm thinking about grabbing full chapter content out of a page with JS, then breaking each chapter down into pages based on line length and lines per page, but that seems sort of crazy, and I'm having trouble returning it to a UIWebView as valid html or javascript code. (The text contains single quotes, etc.)
Use UIWebView Pagination :)
myWebView.paginationMode = UIWebPaginationModeLeftToRight;
myWebView.paginationBreakingMode = UIWebPaginationBreakingModePage;
myWebView.gapBetweenPages = 50;
For font scaling, you need to inject css thru javascript for webkit's font scaling property
http://css-infos.net/property/-webkit-text-size-adjust

Resources