I have the following minimal dot code:
digraph {
charset = utf8;
rankdir = LR;
"ε" -> "V" [label="V:V"];
"ε" -> "ε" [label="C:C"];
"V" -> "V" [label = "C:C"];
"V" -> "ε" [label = "V:V́ "];
}
Note that the last V in the last line is followed by an acute combining diacritic (it is correctly combined with the V in my editor, FWIW). This diacritic does not appear high enough over the V after calling dot -Tpdf foo.dot -o foo.pdf. Instead, as you can see below, it is overlaid:
How do I fix this? I'm using dot version 2.38.0 on Ubuntu (xenial).
I think this works already. If you look closely at your image, you will see the diacritic:
I think it's just the font that needs to be changed. Referring to Graphviz: change font for the whole graph?, I modified your dot code and added a font:
digraph {
graph [fontname = "helvetica"];
node [fontname = "helvetica"];
edge [fontname = "helvetica"];
charset = utf8;
...
This is what I get:
Related
Here's my code below. AHK file is saved as UTF-8 with BOM and I can see the unicode characters just fine whenever I paste it into the script. But everytime I save the script and re-open it, the unicode characters become question marks and random gibberish characters. When "sendinput" is run, the output also comes out as question marks and gibberish, instead of the actual unicode emoticons.
MyVarEmoticon =
(Ltrim
What is your choice? (Enter #):
1. (╯°□°)╯︵ ┻━┻
2. (┛ಠ_ಠ)┛彡┻━┻
3. (╯°Д°)╯︵/(.□ . \)
4. ┏━┓┏━┓┏━┓ ︵ /(^.^/)
)
InputBox, MyVarEmoticonChoices, Emoticon Choices, %MyVarEmoticon%, , 400, % HEmoticon(MyVarEmoticon),,,,,1
HEmoticon(MyVarEmoticon)
{
StringReplace, MyVarEmoticon,myvaremoticon,`n,`n,UseErrorLevel
Lines:=ErrorLevel+1
height:=lines * 30 ; play with this value !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;MsgBox % height
If (Height < 40) ; too low
Height+=80
Return height
}
if ErrorLevel {
;MsgBox, CANCEL was pressed.
} else {
if (MyVarEmoticonChoices = "1"){
MyVarEmoticonChoices = (╯°□°)╯︵ ┻━┻
}
if (MyVarEmoticonChoices = "2"){
MyVarEmoticonChoices = (┛ಠ_ಠ)┛彡┻━┻
}
if (MyVarEmoticonChoices = "3"){
MyVarEmoticonChoices = (╯°Д°)╯︵/(.□ . \)
}
if (MyVarEmoticonChoices = "4"){
MyVarEmoticonChoices = ┏━┓┏━┓┏━┓ ︵ /(^.^/)
}
WinGetPos, X, Y, Width, Height, ahk_exe ToW.exe, , ,
XVar = %X%
YVar = %Y%
WVar = %Width%
HVar = %Height%
XWVar = % XVar+39
YHVar = % YVar+682
Sleep,200
sendinput, {raw}%MyVarEmoticonChoices%
Although there are some quite weird things in this code, it seems to work as expected if saved with the correct encoding.
I can't really know what goes wrong when you're trying to save it, maybe try to explain the steps you take to save it in the editor you're using.
If you don't want to worry about file encoding, you could store the characters as code points for example.
You can find a quick little converter with a Google search, here is the one I landed on with a Google search:
http://unicode.scarfboy.com/?s=%28%E2%95%AF%C2%B0%E2%96%A1%C2%B0%29%E2%95%AF%EF%B8%B5+%E2%94%BB%E2%94%81%E2%94%BB
And then you can convert to the code points to characters with Chr().
For example:
emote := "0028 256F 00B0 25A1 00B0 0029 256F FE35 0020 253B 2501 253B"
for each, codepoint in StrSplit(emote, " ")
output .= Chr("0x" codepoint)
Clipboard := output
SendInput, ^v
And here I'm also utilizing the clipboard and sending Ctrl+v, which is a good trick if you can use it. Especially for long text, which this really isn't I guess, but I figured I'd show it.
Or if you want to Send the string, you can use the Unicode notation:
emote := "0028 256F 00B0 25A1 00B0 0029 256F FE35 0020 253B 2501 253B"
for each, codepoint in StrSplit(emote, " ")
output .= "{U+" codepoint "}"
SendInput, % output
;SendInput, % "{U+0028}{U+256F}{U+00B0}{U+25A1}{U+00B0}{U+0029}{U+256F}{U+FE35}{U+0020}{U+253B}{U+2501}{U+253B}"
In ahk script files you must choose UTF-16 LE BOM Encoding to support Unicode characters. That's a Microsoft Windows default behaviour which indicates all other encodings as ASCII.
How can I make a VSCode extension folding strategy based on the first blank line following a starting folding marker?
## Some section --|
Any text... | (this should fold)
...more text. --|
(blank line)
## Another section (next fold...)
I've tried lots of regex in the language-configuration.json.
"folding": {
"markers": {
"start": "^##",
"end": "^\\s*$"
} },
If I change things to test with something other than a blank (or whitespace) line as the end delimiter it works. Can't use the next start marker to mark the end of the last or it includes it in the fold (I tried look ahead regex, but I think the regex are applied line by line and the matches can't span lines?)
It's similar to the folding needed for Markdown which VSCode handles well (don't know if that's using a more complex method like https://code.visualstudio.com/api/references/vscode-api#FoldingRangeProvider).
Maybe something in the fixes for [folding] should not fold white space after function has something to do with it.
What I learned: 1. the begin and end regex are applied line by line. 2. tmLanguage start/end regex will work on blank lines, but currently language-configuration folding doesn't seem to work on blank lines.
And since blank lines are in this case a hack for ending at the next begin section:
To solve the problem of folding a section to the next similar section I used the FoldingRangeProvider.
disposable = vscode.languages.registerFoldingRangeProvider('myExt', {
provideFoldingRanges(document, context, token) {
//console.log('folding range invoked'); // comes here on every character edit
let sectionStart = 0, FR = [], re = /^## /; // regex to detect start of region
for (let i = 0; i < document.lineCount; i++) {
if (re.test(document.lineAt(i).text)) {
if (sectionStart > 0) {
FR.push(new vscode.FoldingRange(sectionStart, i - 1, vscode.FoldingRangeKind.Region));
}
sectionStart = i;
}
}
if (sectionStart > 0) { FR.push(new vscode.FoldingRange(sectionStart, document.lineCount - 1, vscode.FoldingRangeKind.Region)); }
return FR;
}
});
Set "editor.foldingStrategy": "auto". You can make it more sophisticated to preserve white space between sections.
I have a problem removing the text and special characters from the string. For eg:
str = 'Accleration [ms^{{-}2}]';
The expected output: str_out = 'Acceleration'; I tried using the function regexprep but couldn't get the result as expected.
You can try
opens = str == '[';
closes = str == ']';
nestingcount = cumsum(opens - [0 closes(1:end-1)]);
outstr = str(nestingcount == 0);
Note that trimming trailing spaces was not part of your specification, you'll have to do that as well to get your example to work right.
I am essentially making a teleprompter app and I need a UITextView to display right to left for EVERY line.
NSString *textString = #"Hello There\nMy name is Mark";
textView.text = [#"\u202B" stringByAppendingString: textString];
This is not working. I need this to read
" erehT olleH"
" kraM si eman yM"
I understand that I also need fonts that are upside down etc.. I need to get this part fixed first. Thanks.
The notation \u202b denotes the Unicode character U+202B is RIGHT-TO-LEFT EMBEDDING, which does not affect the writing direction of characters with strong directionality, such as Latin letters.
The character U+202E RIGHT-TO-LEFT OVERRIDE (\u202e) forces right-to-left writing direction, overriding the inherent directionality of characters. To end its effect, use the U+202C POP DIRECTIONAL FORMATTING character:
'\u202eHello There\nMy name is Mark \u202c'
This has little to do with fonts. The rendering engine is supposed to handle some characters like “(” using mirrored symbols, e.g. so that “(foo)” gets rendered as “(oof)” and not “)oof(” in right-to-left writing. But generally, no mirroring is involved; letters remain the same, they just run right to left.
If you actually want to have text mirrored, you need something completely different (a transformation).
This is the logic for reversing the string... I hope this helps you... Just append this string in your textView.text
NSString *sampleString = #"Hello this is sample \n Hello there";
NSMutableString *reverseString = [NSMutableString string];
NSInteger index = [sampleString length];
while (index > 0)
{
index--;
NSRange subStrRange = NSMakeRange(index, 1);
[reverseString appendString:[sampleString substringWithRange:subStrRange]];
}
NSLog(#"%#", reverseString);
I am making a UITextView which is similar to notes.app, where the first line of the textView is used as the title. I need to create a new string which contains only the first line of text. So far I've come up with this:
NSRange startRange = NSMakeRange(0, 1);
NSRange titleRange = [noteTextView.text lineRangeForRange:startRange];
NSString *titleString = [noteTextView.text substringToIndex:titleRange.length];
NSLog(#"The title is: %#", titleString);
The only problem with this is that it relies on the user pressing Return. I've also tried using a loop to find the number of characters in the first line:
CGSize lineSize = [noteTextView.text sizeWithFont:noteTextView.font
constrainedToSize:noteTextView.frame.size
lineBreakMode:UILineBreakModeWordWrap];
int textLength =1;
while ((lineSize.width < noteTextView.frame.size.width) &&
([[noteTextView.text substringToIndex:textLength] length] < [noteTextView.text length]))
{
lineSize = [[noteTextView.text substringToIndex:textLength] sizeWithFont:noteTextView.font
constrainedToSize:noteTextView.frame.size
lineBreakMode:UILineBreakModeWordWrap];
textLength = textLength+1;
}
NSLog(#"Length is %i", textLength);
But I've got this wrong somewhere - it returns the total number of characters, instead of the number on the first line.
Does anyone know an easier/better way of doing this?
There is probably a much better way with CoreText, but I'll throw this out there just because it came to mind off the top of my head.
You could add characters one by one to an NSMutableString *title while
[title sizeWithFont:noteTextView.font].width < noteTextView.frame.size.width
then drop the last one, obviously doing the necessary bounds checking along the way and dropping the last added character if necessary.
But sizeWithFont is sloooooow. So if you're doing this often you might want to consider another definition of 'title' - say, at first word break after 20 chars.
But again, CoreText might yield more possibilities.
I do not understand the code you're having above. Wouldn't it be simpler do just find the first line of text in the string, e.g. until a CR or LF terminates the first line?
And if there is no CR or LF, then you take the entire text as you have only one line then.
Of course, this will give you not what is visible in the first line in case the line is longer and gets wrapped, but I think that using lineRangeForRange doesn't do this, either, or does it?
And if your only concern is that "the user has to press enter" to make it work, then why not simply append a newline char to the text before testing for the first line's length?
See how many characters can fit in one line of your text view and use that number in a substringToIndex: method. Like this:
Type out the same character repeatedly and count how many fit in one line. Make sure to use a wide letter to ensure reliability. Use a capital g or m or q or w or whatever is widest in the font you're using.
Say 20 characters can fit in one line.
Then do
NSString *textViewString = notesTextView.text;
NSString *titleString = [textViewString substringToIndex:20]
Just use the titleString as the title.