首页 \ 问答 \ 更好的SVG旋转文本渲染(Better SVG rotated text rendering)

更好的SVG旋转文本渲染(Better SVG rotated text rendering)

我想知道是否有办法更好地渲染svg旋转文本?

<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" width="900" height="400"  xmlns="http://www.w3.org/2000/svg">
     <text x="50" y="50" id="text_0" transform="rotate(17, 50, 50)">
         SVG text test 
    </text>
</svg>

你可以在这里测试这段代码的渲染: http//jsfiddle.net/vbzTd/2/看起来字符不符合基线,我不明白为什么。

非常感谢你的帮助。


I would like to know if there is a way to get a better rendering of svg rotated text?

<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" width="900" height="400"  xmlns="http://www.w3.org/2000/svg">
     <text x="50" y="50" id="text_0" transform="rotate(17, 50, 50)">
         SVG text test 
    </text>
</svg>

You can test the render of this code here: http://jsfiddle.net/vbzTd/2/ It seems like characters are not following the baseline and I don't understand why.

Thanks a lot for your help.


原文:https://stackoverflow.com/questions/15385911
更新时间:2022-03-27 17:03

最满意答案

不,您不应该为此目的抛出ArgumentNullException ,因为它专为解决null引用而设计。

引用(在Visual Basic中为Nothing)传递给不接受它作为有效参数的方法时引发的异常。

相反,你应该使用ArgumentException或你自己的子类。 让我们说InvalidUserException或类似的东西。

即使是msdn谈论

ArgumentNullException的行为与ArgumentException相同。 它提供的应用程序代码可以区分由空参数引起的异常和由非空参数引起的异常。 对于由非空参数引起的错误

所以很显然,如果argument为null ,则使用ArgumentNullExceptionArgumentException

也就是说,理想情况下,您甚至不应允许某人使用无效的用户名创建User实例。 我真的设计我的User类,它永远不会包含Namenull


No you shouldn't throw ArgumentNullException for this purpose as it is designed specifically to address null references.

The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

Instead you should be using ArgumentException or your own subclass of it. let's say InvalidUserException or something similar.

Even msdn talks about.

ArgumentNullException behaves identically to ArgumentException. It is provided so that application code can differentiate between exceptions caused by null arguments and exceptions caused by arguments that are not null. For errors caused by arguments that are not null

So it is clear that if argument is null use ArgumentNullException and ArgumentException otherwise.

That said, Ideally you shouldn't even allow someone to create an instance of User with invalid username. I'd really design my User class in such a way that it can never contain Name as null.

相关问答

更多
  • Member x和y是Enclosing非静态数据成员,这意味着它们只存在于Enclosing类的具体对象中。 没有具体的对象, x和y都不存在。 与此同时,你正试图在没有对象的情况下引用x和y 。 这是无法完成的,这正是编译器试图告诉你的。 如果要从x和y初始化成员Inner::foo和Inner::bar ,则必须将Enclosing类型的具体对象传递到Inner的构造函数中。 例如 class Enclosing::Inner { explicit Inner(const Enclosin ...
  • 不,您不应该为此目的抛出ArgumentNullException ,因为它专为解决null引用而设计。 当空引用(在Visual Basic中为Nothing)传递给不接受它作为有效参数的方法时引发的异常。 相反,你应该使用ArgumentException或你自己的子类。 让我们说InvalidUserException或类似的东西。 即使是msdn谈论 。 ArgumentNullException的行为与ArgumentException相同。 它提供的应用程序代码可以区分由空参数引起的异常和由非空 ...
  • 不,类上的static与字段上的static 。 字段mMember是嵌套类StaticNestedClass的私有实例字段。 您可以使用此嵌套类,就像使用任何其他顶级类一样,只要您导入它或使用它引用其包含的类,即。 Outer.StaticNestedClass。 例如, import Outer.StaticNestedClass; ... StaticNestedClass instance = new StaticNestedClass(); 要么 import Outer; ... Oute ...
  • 您是否尝试过使用此处建议的opt.Skip。 Mapper.CreateMap() .ForMember(s => s.S, opt => opt.Skip(src => !string.IsNullOrWhiteSpace(src.S))); 编辑: 经过一些挖掘源头。 我在TypeMapObjectMapperRegistry类(处理嵌套对象的映射的类)中看到它返回,然后查看是否需要保留目标值(使用UseDestinationValue)。 否则,我会建议: Ma ...
  • 考虑以下 namespace A1 { namespace A2 // A1.A2 { class C2 // full name: A1.A2.C2 { private A1.C1 c1b; // full name private C1 c1b; // shortest form. A1 is in scope here } } class C1 // ...
  • 如果你看到你的pt是一个对象[{}]的数组,那么你需要选择你想要访问的元素 var sidOut = block.pt[0].sid; var sumOut = block.pt[0].sum; 应该能得到正确的结果 if you see your pt is an array of an object [{}] so you need to select which element you want to access so var sidOut = block.pt[0].sid; var sumOu ...
  • 如果要将嵌套成员存储在一行中(主成员的同一行,ClassA在您的情况下),您必须将它们标记为ComplexTypes。 [ComplexType] public class ClassB { public int b { get; set; } } [ComplexType] public class ClassC { public int c { get; set; } } 在这种情况下,ClassA表中将包含ClassB和ClassC的列。 要使用此配置,您需要属性ClassA.B和 ...
  • 像这样的东西: class Plass { public: Plass(Point *newPoint, Way *newWay) { moint = newPoint; bay = newWay; // or instantiate here: // moint = new Point(); // bay = new Way(); // just don't forget to me ...
  • 首先,我将指出导致编译器错误的原因。 rule "testnestedmembers" when A(x.y : y, $x : x) // (1) A(x2.y == y, $x : x2) // (2) (3) (1)绑定的格式为 : ,但xy不是有效的变量名。 (2)与x2.y相同。 此外, x2不是A中的字段。(3)没有什么能阻止规则引擎将相同的事实与A类的两个模式匹配。这意味着规则将针对A类的每个事实触发,因为(如你打算)Axy总 ...
  • 你没有改变它的价值。 您刚刚将空引用的副本复制到局部变量中,您将局部变量设置为引用新字符串,但在所有这些中,您从未更改原始引用以引用除null之外的任何内容。 确实,字符串是引用类型,但即使使用引用类型,更改引用本身也不同于更改引用对象的属性。 例如: Foo a = new Foo (); Foo b = a; b.Bar = 7; b = new Foo (); b.Baz = 12; 在这个例子中,a.Bar将是7,因为在那时a和b引用了同一个对象。 然而,a.Baz并未设置为12,因为b被改为指向 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。